package repository;

        import Dto.NewsTbEntity;
        import Dto.UserTbEntity;
        import MEx.MExAPI;
        import dbConnect.dbConnecter;

        import java.sql.ResultSet;
        import java.util.Vector;

public class UserTbRepository {
    public UserTbRepository(){

    }
    public Vector<UserTbEntity> getUserTable()
    {
        dbConnecter Con = new dbConnecter();
        Con.getConnection();
        Vector<UserTbEntity>  userVec=new Vector<UserTbEntity>();
        try {
            String sql = "select * from User_tb";
            ResultSet re = Con.querySql(sql);

            while (re.next()) {
                UserTbEntity userTbEntity = new UserTbEntity();
                userTbEntity.setUserId(re.getString(6));
                userTbEntity.setUserAccount(re.getString(2));
                userTbEntity.setUserName(re.getString(1));
                userTbEntity.setUserType(re.getString(4));
                userTbEntity.setUserStatus(re.getString(5));
                userTbEntity.setAdmin(re.getInt(7));
                System.out.println("account="+re.getString(2));
                userVec.add(userTbEntity);
            }
            return userVec;
        }
        catch (Exception e) {
            e.printStackTrace();
            return null;
        }
        finally {
            Con.close();
        }
    }

}
